package com.mjfeed.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mjfeed.entity.DeliveryCorp;
import com.mjfeed.service.DeliveryCorpService;
import com.mjfeed.util.Pagination;
import com.mjfeed.util.ParamBean;
import com.mjfeed.util.QueryCondition;

@Service("deliveryCorpService")
public class DeliveryCorpServiceImpl extends BaseServiceImpl implements DeliveryCorpService {

	@Transactional(readOnly = true)
	public Pagination<DeliveryCorp> getPagination(ParamBean paramBean) {
		List<QueryCondition> queryConditions = new ArrayList<QueryCondition>();
		if (StringUtils.isNotBlank(paramBean.getKeyword())) {
			queryConditions.add(new QueryCondition(paramBean.getField(), QueryCondition.LK, paramBean.getKeyword()));
		}
		String orderBy = "order by orders asc";
		Pagination<DeliveryCorp> pagination = (Pagination<DeliveryCorp>)getPagination(DeliveryCorp.class, queryConditions, orderBy, paramBean.getPage(), paramBean.getPageSize());
		pagination.setPageHtml(paramBean.getUrl());
		return pagination;
	}
}
